<?php

class SoapClientDebug extends SoapClient {
  public function __doRequest($request, $location, $action, $version, $one_way = null) {
    $request = $_POST["xml"];
    $rsRespuesta = parent::__doRequest($request, $location, $action, $version, $one_way);
    return $rsRespuesta;
  }
}

if($_POST["paso"] == "2") {
  $ini = ini_set("soap.wsdl_cache_enabled","0");
  $arrHeaders["trace"       ] = 1;
  $arrHeaders["soap_version"] = SOAP_1_1;
  try {
    $oSoap = new SoapClientDebug("{$_POST["url"]}?WSDL", $arrHeaders);
    eval('$rsResult = $oSoap->' . $_POST["funcion"] . '();');
  } catch(SoapFault $soapFault) {
    $strMensajeError = $soapFault->faultstring;
  }
?>
<html>
  <head>
    <title>Manddo de informacion a Web Service</title>
  </head>
  <body>
    <table>
      <tr>
        <td>Mensaje de error:</td>
        <td><?= $strMensajeError ?></td>
      </tr>
      <tr>
        <td>XML a enviar</td>
        <td><textarea cols='100' rows='20'><?= $_POST["xml"] ?></textarea></td>
      </tr>
      <tr>
        <td>XML Recibido</td>
        <td><textarea cols='100' rows='20'><?= $oSoap->__last_response ?></textarea></td>
      </tr>
    </table>
  </body>
</html>
<?php
} else {
?>
<html>
  <head>
    <title>Manddo de informacion a Web Service</title>
  </head>
  <body>
    <form action="envio_xml.php" method="POST">
      <input type="hidden" name="paso" value="2" />
      <table>
        <tr>
          <th colspan="2">Datos para envio</th>
        </tr>
        <tr>
          <td>URL Servicio:</td>
          <td><input type="text" name="url" size="60" value="http://200.57.181.84/EOL.AutoIndividual.WSSetup/WSEmision.asmx" /></td>
        </tr>
        <tr>
          <td>Funci&oacute;n:</td>
          <td><input type="text" name="funcion" value="GenerarEmision" /></td>
        </tr>
        <tr>
          <td>XML a enviar:</td>
          <td><textarea cols="100" rows="30" name="xml"></textarea></td>
        </tr>
        <tr>
          <th colspan="2">
            <input type="submit" value="Enviar" />
          </th>
        </tr>
      </table>
    </form>
  </body>
</html>
<?php
}

?>